package com.fy.springcloud.message;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.support.MessageBuilder;

import java.util.Date;

@EnableBinding(Source.class)
public class MessageSender {

    @Autowired
    private MessageChannel output;

    public void publish(String msg) {
        boolean flag = output.send(MessageBuilder.withPayload(msg).build());
        System.out.println("发送消息：" + msg + "  发送时间：" + new Date() + " 发送状态：" + flag);
    }
}
